<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <title>编辑物业公司</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <style type="text/css">

    </style>
    <script type="text/css">
        body{text-align:center;}
    </script>
</head>

<body>
    <div style="position:absolute;top:20%;left:5%;width:80%;height:80%">
        <div class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label" style="float:left;width:20%">物业公司</label>
                <div class="layui-input-block">
                    <input style="width:75%" id="areaname" type="text" name="areaname" required lay-verify="required" placeholder="请输入物业公司" autocomplete="off" class="layui-input">
                    <input id="id" type="text" name="id" style="display:none">
                </div>
            </div>
            <div></div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="float:left;width:20%">开始服务日期</label>
                <div class="layui-input-block">
                    <input style="width:75%" id="bdate" type="text" name="bdate" required lay-verify="required" placeholder="请选择日期" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div></div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="float:left;width:20%">备注</label>
                <div class="layui-input-block">
                    <textarea style="width:75%" id="memo" type="textarea" name="memo" placeholder="请输入备注" autocomplete="off" class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn " lay-submit lay-filter="edit">保存</button>
                    <button class="layui-btn layui-btn-primary" id="close">取消</button>
                </div>
            </div>
        </div>
    </div>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'user'], function() {
            var $ = layui.$,
                setter = layui.setter,
                admin = layui.admin,
                form = layui.form,
                router = layui.router(),
                search = router.search;

            form.render();

            //提交
            layui.use('laydate', function() {
                var laydate = layui.laydate;
                //执行一个laydate实例
                laydate.render({
                    elem: '#bdate' //指定元素
                });
            });

            form.on('submit(edit)', function(obj) {
                admin.req({
                    url: "../../../Area/saveexedit",
                    type: "post",
                    datatype: "json",
                    data: obj.field,
                    success: function(res) {
                        if (res.data == "ok") {
                            layer.msg('编辑成功', {
                                offset: 'auto',
                                icon: 1,
                                time: 1500,
                                end: function() {
                                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                    parent.layer.close(index); // 关闭layer
                                    window.parent.location.reload(); //刷新父页面
                                }
                            })
                        } else if (res.data == '无权限') {
                            layer.msg('没有权限，编辑失败', {
                                offset: 'auto',
                                icon: 2,
                                time: 1000,
                                end: function() {
                                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                    parent.layer.close(index);
                                }
                            })
                        } else {
                            layer.msg('编辑失败', {
                                offset: 'auto',
                                icon: 2,
                                time: 1000,

                            })
                        }
                    },

                    error: function(res) {
                        layer.msg('编辑失败', {
                            offset: 'auto',
                            icon: 2,
                            time: 1000
                        })
                    }
                })

            });
            $("#close").on("click", function() {
                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                parent.layer.close(index); // 关闭layer
            });
        });
    </script>

</body>

</html>